{include file="common/head"/}
<div class="admin-main fadeInUp animated">
    <fieldset class="layui-elem-field layui-field-title">
        <legend>修改栏目</legend>
    </fieldset>
    <form class="layui-form layui-form-pane">
        <input type="hidden" name="id" value="{$info.id}">
        <div class="layui-form-item">
            <label class="layui-form-label">上级栏目</label>
            <div class="layui-input-3">
                <select name="pid" id="parentid">
                    <option value="0">作为一级栏目</option>
                    {volist name="category" id="vo"}
                    <option {if condition="$info.pid eq $vo.id"}selected{/if} value="{$vo.id}">{if condition="$vo.lev eq 1"}|- {elseif condition="$vo.lev eq 2"}|- - {elseif condition="$vo.lev eq 3"}|- - - {/if}{$vo.category_name}</option>
                    {/volist}
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">栏目名称</label>
            <div class="layui-input-4">
                <input type="text" name="category_name" value="{$info.category_name}" lay-verify="required" placeholder="{:lang('pleaseEnter')}栏目名称" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux red">*</div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">栏目图片</label>
            <input type="hidden" name="image" id="image" value="{$info.image}">
            <div class="layui-input-block">
                <div class="layui-upload">
                    <button type="button" class="layui-btn layui-btn-primary" id="cateBtn"><i class="icon icon-upload3"></i>点击上传</button>
                    <div class="layui-upload-list">
                        <img class="layui-upload-img" id="cateImage" src="{$info.image}">
                        <p id="demoText"></p>
                    </div>
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">SEO标题</label>
            <div class="layui-input-block">
                <input type="text" name="seo_title" value="{$info.seo_title}" placeholder="{:lang('pleaseEnter')}SEO标题" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">SEO关键字</label>
            <div class="layui-input-block">
                <textarea placeholder="{:lang('pleaseEnter')}SEO关键字"  name="seo_keywords" class="layui-textarea">{$info.seo_keywords}</textarea>
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">SEO描述</label>
            <div class="layui-input-block">
                <textarea placeholder="{:lang('pleaseEnter')}SEO描述" name="seo_description" class="layui-textarea">{$info.seo_description}</textarea>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="button" class="layui-btn" lay-submit="" lay-filter="submit">{:lang('submit')}</button>
                <a href="{:url('columnUI')}" class="layui-btn layui-btn-primary">{:lang('back')}</a>
            </div>
        </div>
    </form>
</div>
{include file="common/foot"/}
<script src="/public/static/common/js/jquery.2.1.1.min.js"></script>
<script>



            var datas = "<option value=''>请选择</option>";
            var moduleid =  $('#moduleid').val();
            var image = '';

            layui.use(['form','upload'], function () {
                var form = layui.form,upload = layui.upload;
                //普通图片上传
                var uploadInst = upload.render({
                    elem: '#cateBtn',
                    url: '{:url("UpFiles/upload")}',
                    done: function(res){
                        if(res.code>0){
                            $('#image').val(res.url);
                            $('#cateImage').attr('src', res.url);
                        }else{
                            //如果上传失败
                            return layer.msg('上传失败');
                        }
                    },
                    error: function(){
                        //演示失败状态，并实现重传
                        var demoText = $('#demoText');
                        demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-mini demo-reload">重试</a>');
                        demoText.find('.demo-reload').on('click', function(){
                            uploadInst.upload();
                        });
                    }
                });

                form.on('submit(submit)', function (data) {
                    var loading = layer.load(1, {shade: [0.1, '#fff']});
                    $.post("{:url('columnEdit')}", data.field, function (res) {
                        layer.close(loading);
                        if (res.code > 0) {
                            layer.msg(res.msg, {time: 1800, icon: 1}, function () {
                                location.href = res.url;
                            });
                        } else {
                            layer.msg(res.msg, {time: 1800, icon: 2});
                        }
                    });
                });
                form.on('select(moduleid)', function(data){
                    showtemplist(data.value,0,form);
                });
            });
            function showtemplist(m,t,form){
                var type='_list';
                if(t){
                    type='_index';
                }
                var mtlist = modulearr[m]+type;
                var mtshow = modulearr[m]+'_show';

                if(modulearr[m]=='page'){
                    $('.tlist').hide();
                    mtlist=mtshow ='page';
                }else{
                    $('.tlist').show();
                }

                if(modulearr[m]=='page'){
                    mtlist=mtshow ='page';
                }
                $('#template_list').html(datas);
                $('#template_show').html(datas);

                listdatas = showdatas ='';
                for(i=1;i<templatearr.length;i++){
                    data = templatearr[i].split(',');
                    if(data[0].indexOf(mtlist)  >= 0){
                        listdatas  ="<option value='"+data[0]+"'>"+data[1]+"</option>";
                        $('#template_list').append(listdatas);
                    }
                    if(data[0].indexOf(mtshow)  >= 0){
                        showdatas ="<option value='"+data[0]+"'>"+data[1]+"</option>";
                        $('#template_show').append(showdatas);
                    }
                }
                if(form){
                    form.render()
                }
            }
            showtemplist(moduleid,{if condition="empty($record['listtype'])"}0{else /}{$record.listtype}{/if});
</script>